Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating spec mutation logic of daemonset, statefulset, and deployment with mergeWithOverwriteWithEmptyValue #3324

Merged

Conversation

davidhaja
Copy link
Contributor

Description:
Previously the opentelemetry operator couldn't remove fields from the spec of deployments, statefulsets, and daemonsets because of the mergeWithOverride merging strategy. (except the nodeselector field due to #2941).
After this PR, the operator will use the mergeWithOverwriteWithEmptyValue merging logic on the spec of the resources, which will allow to remove fields if they are also removed from the opentelemetrycollector CR.

Link to tracking Issue(s): #2947

Testing:

  • e2e tests
    • additionalContainers (covering mutation of []Object field in spec)
    • affinity (covering mutation of Object field in spec)
    • args (covering mutation of map[string]string field in spec)
    • label change
    • annotation change
  • unit tests
    • additionalContainers
    • affinity
    • args
    • label change
    • annotation change
    • immutable label changed
    • immutable selector changed
      Documentation:
      N/A

Limitation:
The daemonset.metadata.annotations, statefulset.metadata.annotations, deployment.metadata.annotations is still being mutated with mergeWithOverride, therefore the operator cannot remove annotations from there.
This isn't the case with daemonset.spec.template.metadata.annotations, statefulset.spec.template.metadata.annotations, deployment.spec.template.metadata.annotations since they are in the spec of the resources.

@davidhaja davidhaja marked this pull request as ready for review October 4, 2024 09:29
@davidhaja davidhaja requested a review from a team as a code owner October 4, 2024 09:29
@davidhaja davidhaja changed the title 2947 updating ds sf depl mutation 2947 Updating spec of daemonset, statefulset, and deployment mutation logic with mergeWithOverwriteWithEmptyValue Oct 4, 2024
@davidhaja davidhaja changed the title 2947 Updating spec of daemonset, statefulset, and deployment mutation logic with mergeWithOverwriteWithEmptyValue Updating spec of daemonset, statefulset, and deployment mutation logic with mergeWithOverwriteWithEmptyValue Oct 4, 2024
@davidhaja davidhaja changed the title Updating spec of daemonset, statefulset, and deployment mutation logic with mergeWithOverwriteWithEmptyValue Updating spec mutation logic of daemonset, statefulset, and deployment with mergeWithOverwriteWithEmptyValue Oct 4, 2024
controllers/common.go Show resolved Hide resolved
controllers/reconcile_test.go Outdated Show resolved Hide resolved
tests/e2e/annotation-change-collector/chainsaw-test.yaml Outdated Show resolved Hide resolved
@jaronoff97 jaronoff97 requested a review from swiatekm October 7, 2024 14:55
@davidhaja davidhaja requested a review from jaronoff97 October 11, 2024 09:37
Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one thought, otherwise I think this looks great. Thank you! @swiatekm @pavolloffay could you take a look here as well please?

internal/manifests/mutate.go Outdated Show resolved Hide resolved
Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the exhaustive tests! I left some minor comments, but I'm fine with merging this PR as is.

@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this shouldn't be a bug_fix. The current behaviour looks like a bug to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it.

@@ -0,0 +1,14 @@
apiVersion: apps/v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason not to put all the assertions in one file for each step, like we do for other tests? This isn't a criticism per se, I'm honestly wondering if this makes the tests easier to maintain. WDYT @open-telemetry/operator-approvers ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... I see the value in that, this certainly increases our surface area for testing. I do think we're generally due for some e2e test maintenance though so maybe we can do that in a follow up?

Copy link
Contributor

@swiatekm swiatekm Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can discuss during the next SIG meeting. But I agree we shouldn't hold up this PR.

@swiatekm swiatekm merged commit b563a6e into open-telemetry:main Oct 31, 2024
36 checks passed
@jaronoff97
Copy link
Contributor

@davidhaja thank you very much for your contribution here 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Determine better strategy for handling map merging for various fields
4 participants